// 注释内容为3.5.0舍弃 页面注释不要删

import toolMgr from '@/biz/base/tool.js'
let _this = null
import ruleOpt from '@/biz/option/rule.js'
import cityMgr from '@/biz/option/city'

function options(vm) {
  _this = vm
  return [
    accessoryImg(_this.acBasicsReq),
    {
      title: '页面标题',
      key: 'titleTag',
      disabled: _this.statusLastFlag,
      placeholder: '参与活动赢好礼',
      input: {
        type: 'text',
        maxlength: 10
      },
      rules: [
        {
          required: true,
          message: '请输入页面标题',
          trigger: 'blur'
        }
      ]
    },
    accessoryImg2(_this.acBasicsReq),
    accessoryImg3(_this.acBasicsReq),
    accessoryImg4(_this.acBasicsReq),

    {
      title: '活动时间',
      key: 'activityTime',
      disabled: _this.statusLastFlag,
      placeholder: '请选择活动时间',
      xl: 4,
      date: {
        type: 'datetimerange',
        format: 'yyyy-MM-dd HH:mm:ss',
        disabled: (date) => {
          // return date.valueOf() <= new Date().getTime()
          return date && date.valueOf() < Date.now() - 86400000
        }
      },
      rules: [
        {
          type: 'array',
          required: true,
          message: '请选择活动时间',
          trigger: 'blur'
        }
      ]
    },
    {
      title: '活动说明',
      key: 'reason',
      disabled: _this.statusLastFlag,
      placeholder: '请输入活动说明',
      tips: '活动介绍、奖品介绍、参与限制、兑奖方式、活动解释等',
      editor: {
        type: 'toolbarList2'
      },
      rules: [
        {
          required: true,
          message: '请输入活动说明',
          trigger: 'blur'
        }
      ]
    },
    {
      title: '联系方式',
      key: 'phone',
      disabled: _this.statusLastFlag,
      placeholder: '请输入联系方式',
      tips: '该联系方式用于奖品兑换页面展示',
      input: {
        maxlength: 11
      },
      rules: [
        {
          required: true,
          message: '请输入联系方式',
          trigger: 'blur'
        }
      ]
    }
    // {
    //   title: '活动责任方',
    //   key: 'responsibility',
    //   placeholder: '请输入活动责任方',
    //   tips: '该名称将用于活动解释及说明',
    //   input: {

    //   },
    //   rules: [{
    //     required: true,
    //     message: '请输入活动责任方',
    //     trigger: 'blur'
    //   }]
    // },
  ]
}

function options2(vm) {
  _this = vm
  console.log(_this.tabsChoose, _this.acPrizeReqList[_this.tabsChoose].name, 'vvvvvv')
  return [
    {
      title: '奖品名称',
      key: 'name',
      disabled: _this.statusLastFlag,
      tips: _this.acPrizeReqList[_this.tabsChoose].name
        ? '若替换奖品，请勿直接修改名称，请删除后重新添加新奖品'
        : '',
      tipsColor: '#ed4014',
      placeholder: '请输入奖品名称(最大8个字符)',
      input: {
        type: 'text',
        maxlength: 8
      },
      rules: [
        {
          required: true,
          message: '请输入奖品名称',
          trigger: 'blur'
        }
      ]
    },
    {
      title: '奖品类型',
      key: 'type',
      disabled: _this.statusLastFlag,
      radio: {
        options: [
          {
            key: '1',
            value: '实物'
          }
        ]
      },
      rules: [
        {
          required: true,
          message: '请选择奖品类型',
          trigger: 'blur'
        }
      ]
    },
    accessoryImg5(),
    {
      title: '奖品数量',
      key: 'count',
      disabled: _this.statusLastFlag,
      placeholder: '请输入奖品数量',
      input: {
        type: 'number'
      },
      change: (res) => {
        console.log(res, _this.acPrizeReqList, '111111111')
        let countFlag = _this.acPrizeReqList.some((item) => {
          return item.count > 0
        })

        if (!countFlag) {
          _this.$Message.warning('至少有一个奖品的数量不为0')
        }
      },
      rules: [
        {
          type: 'number',
          required: true,
          message: '请输入奖品数量',
          trigger: 'blur'
          // }, ruleOpt.positiveInteger()]
        },
        ruleOpt.minNumZero(0)
      ]
    },
    {
      title: '兑奖说明',
      key: 'exchangeReason',
      disabled: _this.statusLastFlag,
      placeholder: '请输入兑奖说明',
      tips: '请填写兑换方法、兑换条件等信息',
      input: {
        type: 'text',
        maxlength: 50
      },
      rules: [
        {
          required: true,
          message: '请输入兑奖说明',
          trigger: 'blur'
        }
      ]
    },
    // optionsRadio(_this),
    optionsCheckBox(_this)
  ]
}

function options3(vm) {
  _this = vm
  return [
    {
      title: '综合中奖率',
      key: 'synthesisWinningRate',
      group: [
        {
          key: 'synthesisWinningRate',
          col: 20,
          disabled: _this.statusLastFlag,
          placeholder: '请输入综合中奖率',
          tips: '请填写本次活动的预计中奖率，如人人都可获奖，综合中奖率为100%',
          input: {
            type: 'number'
          }
        },
        {
          placeholder: '%',
          col: 4,
          text: {}
        }
      ],
      rules: [
        {
          type: 'number',
          required: true,
          message: '请输入综合中奖率',
          trigger: 'blur'
        },
        ruleOpt.twoDecimal(),
        ruleOpt.percent(),
        ruleOpt.minNum(0)
      ]
    },
    {
      title: '初始抽奖次数',
      key: 'initialLotteryCount',
      disabled: _this.statusLastFlag,
      group: [
        {
          key: 'initialLotteryCount',
          disabled: _this.statusLastFlag,
          col: 20,
          placeholder: '请输入抽奖次数',
          input: {
            type: 'number'
          }
        },
        {
          placeholder: '次',
          col: 4,
          text: {}
        }
      ],
      rules: [
        {
          type: 'number',
          required: true,
          message: '请输入抽奖次数',
          trigger: 'blur'
        },
        ruleOpt.positiveNumber()
      ]
    },
    {
      title: '中奖次数',
      key: 'winningCount',
      disabled: _this.statusLastFlag,
      group: [
        {
          placeholder: '每人最多可中奖',
          col: 5,
          text: {}
        },
        {
          key: 'winningCount',
          disabled: _this.statusLastFlag,
          col: 15,
          placeholder: '请输入中奖次数',
          input: {
            type: 'number'
          }
        },
        {
          placeholder: '次',
          col: 4,
          text: {}
        }
      ],
      rules: [
        {
          type: 'number',
          required: true,
          message: '请输入中奖次数',
          trigger: 'blur'
        },
        ruleOpt.positiveInteger()
      ]
    },
    winningNumFlag(),
    winningFlag()
  ]
}
// let arr2 = []

function options41(vm) {
  _this = vm
  // let aar = ...locationAll(_this)
  // console.log(locationAll(_this), '11111111111');
  return locationAll(_this)
}
// 添加上去展示
function options4(vm) {
  _this = vm
  return [
    {
      title: '授权手机号参与',
      key: 'phoneAuthorization',
      disabled: _this.statusLastFlag,
      placeholder: '授权手机号参与',
      tips: '启用后，用户必须授权手机号后才可参与活动',
      tipsIsBlock: 'Dinline',
      disabled: true,
      switch: {
        openText: '启用',
        closeText: '关闭',
        size: 'large'
      }
    },
    {
      title: '限定地点参与',
      key: 'locationLimitation',
      disabled: _this.statusLastFlag,
      placeholder: '限定地点参与',
      tips: '启用后，用户必须授权地理位置后才可参与活动',
      tipsIsBlock: 'Dinline',
      switch: {
        openText: '启用',
        closeText: '关闭',
        size: 'large'
      },
      change: (res) => {
        _this.upAddShow(res.value)
      }
    }
  ]
}

function locationAll(_this) {
  let rangeOpt = [
    {
      title: '',
      key: 'signAddress',
      col: 8,
      disabled: true,
      visible:
        _this.acParticipationTaskReqList.locationLimitation &&
        _this.acParticipationTaskReqList.locationOptions == '0',
      // visible: _this.acParticipationTaskReqList.locationLimitation, //本期只要范围
      placeholder: '请设置地点',
      input: {}
      // rules: [{
      //   required: true,
      //   message: '请设置地点',
      //   trigger: 'change'
      // }],
    },
    {
      title: '',
      key: 'scope',
      col: 8,
      visible:
        _this.acParticipationTaskReqList.locationLimitation &&
        _this.acParticipationTaskReqList.locationOptions == '0',
      // visible: _this.acParticipationTaskReqList.locationLimitation, //本期只要范围
      group: [
        {
          key: 'scope',
          col: 16,
          disabled: true,
          placeholder: '请设置范围',
          input: {}
        },
        {
          placeholder: '米',
          col: 4,
          text: {}
        },
        {
          col: 4,
          disabled: _this.statusLastFlag,
          button: {
            title: '去设置',
            click: (val) => {
              _this.mapClick()
            }
          }
        }
      ],
      rules: [
        {
          required: true,
          message: '请设置范围',
          trigger: 'change'
        }
      ]
    }
  ]

  let cityOpt = cityMgr.city({
    info: _this.acParticipationTaskReqList,
    checkLevel: 'level1',
    col: 18,
    visible:
      _this.acParticipationTaskReqList.locationLimitation &&
      _this.acParticipationTaskReqList.locationOptions == '1'
  })

  let addRemove = {
    title: '',
    key: '',
    col: 3,
    // visible: _this.acParticipationTaskReqList.locationLimitation,
    group: [
      {
        col: 12,
        button: {
          style: `font-size:25px;`,
          type: 'text',
          title: `-`,
          click: (val) => {
            // _this.mapClick()
            console.log(val, '33333333')
          }
        }
      },
      {
        col: 12,
        button: {
          type: 'text',
          style: `font-size:25px;`,
          title: `+`,
          click: (val) => {
            _this.upAdd()
            console.log(val, '1111111')
            // // arr2.push(regionOpt)
            // // console.log(arr2, 'dddddddd');
            // _this.upAdd()
          }
        }
      }
    ]
  }

  let regionOpt = [
    {
      title: '',
      key: 'locationOptions',
      // disabled: _this.statusLastFlag,
      placeholder: '请选择',
      // visible: _this.acParticipationTaskReqList.locationLimitation,
      col: 6,
      select: {
        options: [
          { key: '0', value: '限定范围' },
          { key: '1', value: '限定地区' }
        ]
      },
      change: (val) => {
        console.log(val, '13333')
        console.log(val.value, '限定什么')
        if (val.value === '0') {
          rangeOpt.visible = true
          cityOpt.visible = false
        } else {
          rangeOpt.visible = false
          cityOpt.visible = true
        }

        console.log(regionOpt, 'regionOptregionOptregionOpt')
      }
    },
    ...rangeOpt,
    cityOpt,
    addRemove
  ]
  // let arr = [
  //   // {
  //   //   title: '限定地点参与',
  //   //   key: 'locationLimitation',
  //   //   disabled: _this.statusLastFlag,
  //   //   placeholder: '限定地点参与',
  //   //   tips: '启用后，用户必须授权地理位置后才可参与活动',
  //   //   tipsIsBlock: 'Dinline',
  //   //   switch: {
  //   //     openText: '启用',
  //   //     closeText: '关闭',
  //   //     size: 'large',

  //   //   },
  //   //   change: (res) => {
  //   //     if (res.value) {
  //   //       regionOpt[0].visible = true

  //   //       rangeOpt[0].visible = true
  //   //       rangeOpt[1].visible = true
  //   //     } else {
  //   //       regionOpt[0].visible = false
  //   //       rangeOpt[0].visible = false
  //   //       rangeOpt[1].visible = false
  //   //       cityOpt.visible = false
  //   //       _this.participation.locationOptions = '0'

  //   //     }
  //   //   },

  //   // },
  //   regionOpt

  // ]
  console.log(regionOpt, 'regionOpt')
  return regionOpt
}

// function locationAll(_this) {
//   let rangeOpt = [{
//     title: '',
//     key: 'signAddress',
//     col: 7,
//     disabled: true,
//     // visible: _this.acParticipationTaskReqList.locationLimitation, //本期只要范围
//     visible: _this.acParticipationTaskReqList.locationLimitation && _this
//       .acParticipationTaskReqList.locationOptions == '0',
//     placeholder: '请设置地点',
//     input: {},
//     // rules: [{
//     //   required: true,
//     //   message: '请设置地点',
//     //   trigger: 'change'
//     // }],

//   }, {
//     title: '',
//     key: 'scope',
//     col: 7,
//     visible: _this.acParticipationTaskReqList.locationLimitation && _this
//       .acParticipationTaskReqList.locationOptions == '0',
//     // visible: _this.acParticipationTaskReqList.locationLimitation, //本期只要范围
//     group: [{
//       key: 'scope',
//       col: 15,
//       disabled: true,
//       placeholder: '请设置范围',
//       input: {},

//     }, {
//       placeholder: '米',
//       col: 3,
//       text: {},
//     }, {
//       col: 4,
//       disabled: _this.statusLastFlag,
//       button: {
//         title: '去设置',
//         click: (val) => {
//           _this.mapClick()
//         }
//       },

//     }],
//     rules: [{
//       required: true,
//       message: '请设置范围',
//       trigger: 'blur'
//     }],
//   }]

//   let cityOpt = cityMgr.city({
//     info: _this.acParticipationTaskReqList,
//     checkLevel: 'level1',
//     labelWidth: 100,
//     col: 14,
//     visible: _this.acParticipationTaskReqList.locationLimitation && _this
//       .acParticipationTaskReqList.locationOptions == '1',
//   })

//   let addRemove = {
//     title: '',
//     key: '',
//     col: 3,
//     // visible: _this.acParticipationTaskReqList.locationLimitation,
//     group: [{
//       col: 12,
//       button: {
//         style: `font-size:25px;`,
//         type: 'text',
//         title: `-`,
//         click: (val) => {
//           // _this.mapClick()
//           console.log(val, '33333333');
//         }
//       },

//     }, {
//       col: 12,
//       button: {
//         type: 'text',
//         style: `font-size:25px;`,
//         title: `+`,
//         click: (val) => {
//           console.log(val, '1111111');
//           // arr2.push(regionOpt)
//           // console.log(arr2, 'dddddddd');
//           _this.upAdd()
//         }
//       },

//     }]
//   }

//   let regionOpt = [{
//       title: '',
//       key: 'locationOptions',
//       disabled: _this.statusLastFlag,
//       // disabled: true,
//       placeholder: '请选择',
//       // visible: _this.acParticipationTaskReqList.locationLimitation,
//       col: 6,
//       select: {
//         options: [
//           { key: '0', value: '限定范围' },
//           { key: '1', value: '限定地区' },
//         ]
//       },
//       change: (val) => {
//         console.log(val.value, '限定什么');
//         if (val.value === '0') {
//           rangeOpt[0].visible = true
//           rangeOpt[1].visible = true
//           cityOpt.visible = false
//         } else {
//           rangeOpt[0].visible = false
//           rangeOpt[1].visible = false

//           cityOpt.visible = true
//         }

//         console.log(regionOpt, 'regionOptregionOptregionOpt');
//       },
//     },
//     ...rangeOpt,
//     cityOpt,
//     addRemove
//   ]
//   // arr2.push(regionOpt)

//   // console.log(arr2, '11111111113');
//   // let arr = [{
//   //     title: '限定地点参与',
//   //     key: 'locationLimitation',
//   //     disabled: _this.statusLastFlag,
//   //     placeholder: '限定地点参与',
//   //     tips: '启用后，用户必须授权地理位置后才可参与活动',
//   //     tipsIsBlock: 'Dinline',
//   //     switch: {
//   //       openText: '启用',
//   //       closeText: '关闭',
//   //       size: 'large',

//   //     },
//   //     change: (res) => {
//   //       if (res.value) {
//   //         regionOpt[0].visible = true

//   //         rangeOpt[0].visible = true
//   //         rangeOpt[1].visible = true

//   //         addRemove.visible = true
//   //       } else {
//   //         regionOpt[0].visible = false
//   //         rangeOpt[0].visible = false
//   //         rangeOpt[1].visible = false
//   //         addRemove.visible = false
//   //         cityOpt.visible = false
//   //         _this.participation.locationOptions = '0'

//   //       }
//   //     },

//   //   }, regionOpt

//   // ]

//   return regionOpt
// }

function options5(vm) {
  _this = vm
  return [...assistAll(_this), ...shareAll(_this)]
}
export default {
  options,
  options2,
  options3,
  options4,
  options41,
  options5
}

function winningNumFlag() {
  let opt = {
    title: '整个活动(非单人)每日最多中奖',
    key: 'everydayWinningCount',
    disabled: _this.statusLastFlag,
    visible: _this.acLotteryReq.everydayWinning == '1',
    labelWidth: 240,
    group: [
      {
        key: 'everydayWinningCount',
        disabled: _this.statusLastFlag,
        col: 20,
        placeholder: '整个活动(非单人)每日最多中奖',
        input: {
          type: 'number'
        }
      },
      {
        placeholder: '次',
        col: 4,
        text: {}
      }
    ],
    rules: [
      {
        type: 'number',
        required: true,
        message: '请输入整个活动(非单人)每日最多中奖',
        trigger: 'blur'
      },
      ruleOpt.positiveInteger(),
      ruleOpt.maxNum(10000)
    ]
  }
  return [
    {
      title: '每日中奖次数',
      key: 'everydayWinning',
      disabled: _this.statusLastFlag,
      col: 9,
      radio: {
        options: [
          { key: '0', value: '不限' },
          { key: '1', value: '限制' }
        ]
      },
      change: (val) => {
        if (val.value == 1) {
          opt.visible = true
        } else {
          opt.visible = false
        }
      },
      rules: [
        {
          required: true,
          message: '请选择每日中奖次数',
          trigger: 'blur'
        }
      ]
    },
    opt
  ]
}

function winningFlag() {
  let opt = {
    title: '活动参加',
    key: 'winningLimitCount',
    disabled: _this.statusLastFlag,
    // noDisplay: true,
    visible: _this.acLotteryReq.winningLimit == '1',
    group: [
      {
        key: 'winningLimitCount',
        disabled: _this.statusLastFlag,
        col: 8,
        placeholder: '请输入活动参加',
        input: {
          type: 'number'
        }
      },
      {
        placeholder: '次后才可中奖',
        col: 16,
        text: {}
      }
    ],
    rules: [
      {
        type: 'number',
        required: true,
        message: '请输入活动参加次数',
        trigger: 'blur'
      },
      ruleOpt.positiveInteger()
    ]
  }

  return [
    {
      title: '中奖限制',
      key: 'winningLimit',
      disabled: _this.statusLastFlag,
      col: 10,
      radio: {
        options: [
          { key: '0', value: '不限' },
          { key: '1', value: '限制' }
        ]
      },
      change: (val) => {
        if (val.value == '1') {
          opt.visible = true
        } else {
          opt.visible = false
        }
      },
      rules: [
        {
          required: true,
          message: '请选择中奖限制',
          trigger: 'blur'
        }
      ]
    },
    opt
  ]
}

function optionsCheckBox(_this) {
  let opt = {
    options: _this.optLocation
  }
  return {
    title: '显示位置',
    key: 'showLocation',
    disabled: _this.statusLastFlag,
    checkboxNine: opt,
    change: (res) => {
      _this.locationFn()
      opt.options = _this.optLocation
      if (_this.prizeLocationAll.length == 7) {
        _this.$Message.info('至少保留一个未中奖位置')
      }
    },
    rules: [
      {
        required: true,
        type: 'array',
        message: '请选择奖品位置',
        trigger: 'blur'
      }
    ]
  }
}

// function optionsRadio(_this) {
//   let opt = {
//     options: _this.optLocation
//   }
//   return {
//     title: '显示位置',
//     key: 'showLocation',
//     disabled: _this.statusLastFlag,
//     radioNine: opt,
//     change: (res) => {
//       _this.locationFn()
//       console.log(_this.optLocation, '_this.optLocation');
//       opt.options = _this.optLocation
//     },
//     rules: [{
//       required: true,
//       message: '请选择奖品位置',
//       trigger: 'blur'
//     }]
//   }
// }

function assistAll(_this) {
  let assistOpt = [
    {
      title: '输入视频号ID',
      key: 'videoId',
      disabled: _this.statusLastFlag,
      col: 20,
      visible: _this.assist.seeFlag,
      placeholder: '请输入视频号ID',
      input: {},
      rules: [
        {
          required: true,
          message: '请输入视频号ID',
          trigger: 'blur'
        }
      ]
    },
    {
      title: '输入已发布的的视频内容ID',
      key: 'contentId',
      disabled: _this.statusLastFlag,
      col: 20,
      visible: _this.assist.seeFlag,

      placeholder: '输入输入已发布的的视频内容ID',
      input: {},
      rules: [
        {
          required: true,
          message: '请输入已发布的的视频内容ID',
          trigger: 'blur'
        }
      ]
    },

    {
      title: '视频号观看时长',
      key: 'seeDuration',
      disabled: _this.statusLastFlag,
      visible: _this.assist.seeFlag,

      group: [
        {
          key: 'seeDuration',
          disabled: _this.statusLastFlag,
          col: 10,
          placeholder: '输入视频号观看时长',
          input: {
            type: 'number'
          }
        },
        {
          placeholder: '秒',
          col: 4,
          text: {}
        }
      ],
      rules: [
        {
          type: 'number',
          required: true,
          message: '输入视频号观看时长',
          trigger: 'blur'
        },
        ruleOpt.positiveInteger()
      ]
    },
    {
      title: '获得抽奖次数',
      key: 'getRaffleNum',
      disabled: _this.statusLastFlag,
      visible: _this.assist.seeFlag,

      group: [
        {
          key: 'getRaffleNum',
          disabled: _this.statusLastFlag,
          col: 10,
          placeholder: '输入获得抽奖次数',
          input: {
            type: 'number'
          }
        },
        {
          placeholder: '次',
          col: 4,
          text: {}
        }
      ],
      rules: [
        {
          type: 'number',
          required: true,
          message: '输入获得抽奖次数',
          trigger: 'blur'
        },
        ruleOpt.positiveInteger()
      ]
    }
  ]
  let arr = [
    {
      title: '浏览视频号视频',
      key: 'seeFlag',
      disabled: _this.statusLastFlag,
      tips: '启用后，用户观看视频可额外获得抽奖次数',
      tipsIsBlock: 'Dinline',
      switch: {
        openText: '启用',
        closeText: '关闭',
        size: 'large'
      },
      change: (res) => {
        if (res.value) {
          assistOpt[0].visible = true
          assistOpt[1].visible = true
          assistOpt[2].visible = true
          assistOpt[3].visible = true
        } else {
          assistOpt[0].visible = false
          assistOpt[1].visible = false
          assistOpt[2].visible = false
          assistOpt[3].visible = false
        }
      }
    },
    ...assistOpt
  ]

  return arr
}

function shareAll(_this) {
  let shareOpt = {
    title: '获得抽奖次数',
    key: 'shareNum',
    disabled: _this.statusLastFlag,
    visible: _this.assist.shareFlag,

    group: [
      {
        key: 'shareNum',
        disabled: _this.statusLastFlag,
        col: 10,
        placeholder: '输入获得抽奖次数',
        input: {
          type: 'number'
        }
      },
      {
        placeholder: '次',
        col: 4,
        text: {}
      }
    ],
    rules: [
      {
        type: 'number',
        required: true,
        message: '输入获得抽奖次数',
        trigger: 'blur'
      },
      ruleOpt.positiveInteger()
    ]
  }

  let arr = [
    {
      title: '分享活动',
      key: 'shareFlag',
      disabled: _this.statusLastFlag,
      tips: '启用后，用户分享活动可额外获得抽奖次数',
      tipsIsBlock: 'Dinline',
      switch: {
        openText: '启用',
        closeText: '关闭',
        size: 'large'
      },
      change: (res) => {
        if (res.value) {
          shareOpt.visible = true
        } else {
          shareOpt.visible = false
        }
      }
    },
    shareOpt
  ]

  return arr
}

function accessoryImg(info) {
  let api = toolMgr.unloadFile()
  let files = []
  if (info.accessoryBOList1 && info.accessoryBOList1.length > 0) {
    info.accessoryBOList1.forEach((item) => {
      if (item) {
        files.push({
          name: item.accessoryName,
          url: item.accessoryUrl
        })
      }
    })
  }
  let opt = {
    title: '上传',

    api,
    files,
    multiple: true,
    // disabled: false,
    show: false,
    // hideDel: false,
    hideDel: _this.statusLastFlag,
    maxlength: 1,
    hasCover: false,
    format: ['jpg', 'jpeg', 'png'],
    formatErr: () => {
      this.loading = false
      this.$Message.error('只支持上传jpg、jpeg、png图片！')
    }
    // before: (file) => {
    //   console.log(file, '上传前提前校验图片宽高');
    //   return _this.checkWH(file)
    // },
    // preview: (file) => {
    //   toolMgr.downloadFile(file.url, file.name)
    // }
  }
  return {
    title: '活动封面图',
    key: 'accessoryBOList1',
    disabled: _this.statusLastFlag,
    placeholder: '若封面图不上传，则直接进入活动页，建议上传1125*2172px图片',
    uploadImg: opt,
    data: {
      to: (v) => {
        let accessoryBOList1 = v.map((item) => {
          return {
            name: item.name,
            url: item.response ? item.response.data.imageURL : item.url,
            accessoryName: item.name,
            accessoryUrl: item.response ? item.response.data.imageURL : item.url
          }
        })
        return {
          accessoryBOList1
        }
      }
    }
    // rules: [{
    //   required: true,
    //   message: '请上传图片',
    //   type: 'array',
    //   trigger: 'blur'
    // }]
  }
}

function accessoryImg2(info) {
  let api = toolMgr.unloadFile()
  let files = []
  if (info.accessoryBOList2 && info.accessoryBOList2.length > 0) {
    info.accessoryBOList2.forEach((item) => {
      if (item) {
        files.push({
          name: item.accessoryName,
          url: item.accessoryUrl
        })
      }
    })
  }

  let opt = {
    title: '上传',
    api,
    files,
    multiple: true,

    // disabled: false,
    show: false,
    hideDel: _this.statusLastFlag,
    maxlength: 1,
    hasCover: false,
    format: ['jpg', 'jpeg', 'png'],
    // placeholder: '请上传750*500px，且底部为纯色的图片',
    formatErr: () => {
      this.loading = false
      this.$Message.error('只支持上传jpg、jpeg、png图片！')
    },
    preview: (file) => {
      toolMgr.downloadFile(file.url, file.name)
    }
  }
  return {
    title: '顶部样式',
    key: 'accessoryBOList2',
    disabled: _this.statusLastFlag,
    placeholder: '请上传750*500px，且底部为纯色的图片',
    // col: 12,
    uploadImg: opt,
    data: {
      to: (v) => {
        let accessoryBOList2 = v.map((item) => {
          return {
            name: item.name,
            url: item.response ? item.response.data.imageURL : item.url,
            accessoryName: item.name,
            accessoryUrl: item.response ? item.response.data.imageURL : item.url
          }
        })
        return {
          accessoryBOList2
        }
      }
    }
  }
}

function accessoryImg3(info) {
  let api = toolMgr.unloadFile()
  let files = []
  if (info.accessoryBOList3 && info.accessoryBOList3.length > 0) {
    info.accessoryBOList3.forEach((item) => {
      if (item) {
        files.push({
          name: item.accessoryName,
          url: item.accessoryUrl
        })
      }
    })
  }
  let opt = {
    title: '上传',
    api,
    files,
    multiple: false,
    // disabled: false,
    show: false,
    hideDel: _this.statusLastFlag,
    maxlength: 1,
    hasCover: false,
    format: ['jpg', 'jpeg', 'png'],
    // placeholder: '请上传750*500px，且底部为纯色的图片',
    formatErr: () => {
      this.loading = false
      this.$Message.error('只支持上传jpg、jpeg、png图片！')
    },
    preview: (file) => {
      toolMgr.downloadFile(file.url, file.name)
    }
  }
  return {
    title: '线上售楼处',
    key: 'accessoryBOList3',
    disabled: _this.statusLastFlag,
    placeholder: '请上传750*300px图片，点击将进入线上售楼处',
    // col: 12,
    uploadImg: opt,
    data: {
      to: (v) => {
        let accessoryBOList3 = v.map((item) => {
          return {
            name: item.name,
            url: item.response ? item.response.data.imageURL : item.url,
            accessoryName: item.name,
            accessoryUrl: item.response ? item.response.data.imageURL : item.url
          }
        })
        return {
          accessoryBOList3
        }
      }
    }
  }
}

function accessoryImg4(info) {
  let api = toolMgr.unloadFile()
  let files = []
  if (info.accessoryBOList4 && info.accessoryBOList4.length > 0) {
    info.accessoryBOList4.forEach((item) => {
      if (item) {
        files.push({
          name: item.accessoryName,
          url: item.accessoryUrl
        })
      }
    })
  }

  let opt = {
    title: '上传',
    api,
    files,
    multiple: true,

    // disabled: false,
    show: false,
    hideDel: _this.statusLastFlag,
    drag: !_this.statusLastFlag,
    maxlength: 20,
    hasCover: false,
    format: ['jpg', 'jpeg', 'png'],
    formatErr: () => {
      this.loading = false
      this.$Message.error('只支持上传jpg、jpeg、png图片！')
    },
    preview: (file) => {
      toolMgr.downloadFile(file.url, file.name)
    }
  }
  return {
    title: '项目展示',
    key: 'accessoryBOList4',
    disabled: _this.statusLastFlag,
    placeholder: '可上传多张图片',
    // col: 12,
    uploadImg: opt,
    data: {
      to: (v) => {
        console.log(v, 'dddddddddd')
        let accessoryBOList4 = v.map((item) => {
          return {
            name: item.name,
            url: item.response ? item.response.data.imageURL : item.url,
            accessoryName: item.name,
            accessoryUrl: item.response ? item.response.data.imageURL : item.url
          }
        })
        return {
          accessoryBOList4
        }
      }
    }
  }
}

function accessoryImg5() {
  let api = toolMgr.unloadFile()
  let opt = {
    title: '上传',
    api,
    files: [],
    multiple: false,
    show: false,
    checkFilesLength: true,
    hideDel: _this.statusLastFlag,
    drag: true,
    maxlength: 1,
    hasCover: false,
    format: ['jpg', 'jpeg', 'png'],
    // placeholder: '请上传750*500px，且底部为纯色的图片',
    formatErr: () => {
      this.loading = false
      this.$Message.error('只支持上传jpg、jpeg、png图片！')
    },
    // before: (file) => {
    //   console.log(file, '上传前提前校验图片宽高');
    //   return _this.checkWH(file)
    // },
    preview: (file) => {
      toolMgr.downloadFile(file.url, file.name)
    }
  }
  return {
    title: '奖品图案',
    key: 'accessoryBOList5',
    disabled: _this.statusLastFlag,
    placeholder: '建议上传200*200图片，若不上传则使用默认图',
    // col: 12,
    uploadImg: opt,
    data: {
      from: (info) => {
        let files = []
        if (info.accessoryBOList5 && info.accessoryBOList5.length > 0) {
          info.accessoryBOList5.forEach((item) => {
            if (item) {
              files.push({
                name: item.accessoryName,
                url: item.accessoryUrl
              })
            }
          })
        }
        opt.files = files
      },
      to: (v) => {
        let accessoryBOList5 = v.map((item) => {
          return {
            name: item.name,
            url: item.response ? item.response.data.imageURL : item.url,
            accessoryName: item.name,
            accessoryUrl: item.response ? item.response.data.imageURL : item.url
          }
        })
        return {
          accessoryBOList5
        }
      }
    }
  }
}
